package com.sctvcloud.zhaohua_sd.ui.activities;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;

import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.ruihang.generalibrary.ui.widget.CustomEXImageView;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.sctvcloud.zhaohua_sd.R;
import com.sctvcloud.zhaohua_sd.base.BaseActivity;
import com.sctvcloud.zhaohua_sd.ui.fragment.MyPlatFormFragment;
import com.sctvcloud.zhaohua_sd.ui.utils.GlideCircleTransform;
import com.sctvcloud.zhaohua_sd.ui.utils.GlideUtil;
import com.sctvcloud.zhaohua_sd.utils.UserManager;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class MyPageActivity extends BaseActivity {
    @BindView(R.id.item_rebllion_avatar)
    protected CustomEXImageView avatar;
    @BindView(R.id.item_rebllion_username)
    protected CustomFontTextView userName;
    @BindView(R.id.title_top_title)
    protected CustomFontTextView title_top_title;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setThisImmersive(true);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mypage);
        ButterKnife.bind(this);
        initUser();
        initViews();
        Bundle bundle = new Bundle();
        bundle.putBoolean("is_mine", true);
        MyPlatFormFragment fragment = new MyPlatFormFragment();
        fragment.setArguments(bundle);
        getSupportFragmentManager()    //
                .beginTransaction()
                .add(R.id.fragment_container,fragment)
                .commit();
    }


    private void initUser() {
        if (UserManager.getInstance().getUser() == null) {
            return;
        }
        userName.setText(UserManager.getInstance().getUser().getNickName());
        String icon = UserManager.getInstance().getUser().getAvatar();
        if (!TextUtils.isEmpty(icon)) {
            GlideUtil.getDynamicGlid(MyPageActivity.this, icon, true).transform(new GlideCircleTransform(MyPageActivity.this))
                    .diskCacheStrategy(DiskCacheStrategy.NONE)
                    .into(avatar);
        }

    }

    private void initViews(){

        title_top_title.setText(getText(R.string.tv_my_homepage));


    }

    @OnClick(value = {R.id.title_top_layout_back})
    public void OnClick(View view) {
        switch (view.getId()) {
            case R.id.title_top_layout_back:
                onBackPressed();
                break;
        }
    }

}
